<div class="card">
  <div class="card-content">
    <div class="columns is-vcentered">
      <div class="column">
      <h2 class="subtitle">Crash Report</h2>
      </div>
      <div class="column is-narrow">
        <%= render "export" %>
      </div>
    </div>
    <table class="table is-fullwidth is-hoverable is-narrow">
      <thead>
        <tr>
          <th data-sort="string">Datetime</th>
          <th data-sort="string">Controller#action</th>
          <th data-sort="string">Method</th>
          <th data-sort="string">Format</th>
          <th></th>
          <th data-sort="string">Path</th>
          <th data-sort="string">Exception</th>
          <th data-sort="string">Backtrace</th>
          <th data-sort="string">Status</th>
          <th data-sort="float">Duration</th>
          <th data-sort="float">Views</th>
          <th data-sort="float">DB</th>
        </tr>
      </thead>
      <tbody>
        <% if @data.empty? %>
          <tr>
            <td colspan="9">We are glad that this list is empty ;)</td>
          </tr>
        <% end %>

        <% @data.each do |e| %>
          <tr>
            <td><%= format_datetime e[:datetime] %></td>
            <td><%= link_to e[:controller] + '#' + e[:action], rails_performance.rails_performance_summary_path({controller_eq: e[:controller], action_eq: e[:action]}), remote: true %></td>
            <td><%= e[:method] %></td>
            <td><%= e[:format] %></td>
            <td><%= bot_icon e["user_agent"] %></td>
            <td><%= link_to_path(e) %></td>
            <td><%= e[:exception] %></td>
            <td class="very-small-text">
              <%= raw e[:backtrace]&.join("<br/>") %>
            </td>
            <td><%= status_tag e[:status] %></td>
            <td class="nowrap"><%= ms e[:duration] %></td>
            <td class="nowrap"><%= ms e[:view_runtime] %></td>
            <td class="nowrap"><%= ms e[:db_runtime] %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
